export let httpGet = (url) => {
	return new Promise((resovle, reject) => {
		uni.request({
			url: url,
			header: {
				'content-type': 'application/x-www-form-urlencoded;charset:utf-8',
				'cookie': uni.getStorageSync("token") || ''
			},
			success: (res) => {
				console.log(res.data);
				let {
					errorCode,
					errorMsg,
					data,
					
				} = res.data
				
				resovle(res.data)
				// if (errorCode == 0) {
				// 	resovle(res.data)
				// 	console.log("net=>"+res.data.data.datas);
				// } else {
				// 	reject(errorMsg)
				// }
			},
			fail: (error) => {
				reject(error)
			}
		});

	})
}
export let httpPost = (url, params,isResult=false) => {
	return new Promise((resovle, reject) => {
		var isFlag=isResult
			uni.request({
					url: url,
					method: 'POST',
					data: params,
					header: {
						'content-type': 'application/x-www-form-urlencoded;charset:utf-8',
						'cookie': uni.getStorageSync("token") || ''
					},
					success: (res) => {
						console.log(res.data)
						if(isFlag){
							resovle(res)
							console.log('这里吗');
						}
						else{
							resovle(res.data)
						}
						
						//cookie持久化存储
						console.log('cooie?' + res.header['Set-Cookie']);
						if(res.header['Set-Cookie']){
							uni.setStorageSync('token', res.header['Set-Cookie'])
						}
						
						
						



				},
				fail: (error) => {
					reject(error)
				}
			});

	})
}
